package com.lvmama.controller.rhino.product;

import com.lvmama.client.rhino.ProductClient;
import com.lvmama.common.result.Result;
import com.lvmama.pojo.entity.rhino.product.ProductDetail;
import com.lvmama.pojo.entity.rhino.searchanalysis.FlowSearchStation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/product")
public class ProductController {

    /**
     *
     */
    @Autowired
    ProductClient productClient;

    @RequestMapping(value = "/productDetail",method = {RequestMethod.GET,RequestMethod.POST})
    public String productDetail(ModelMap model) {
        List<FlowSearchStation> stationList = productClient.productDetail().getData();
        model.addAttribute("stationList", stationList);
        return "pageAnalysis/productDetail";
    }

    @RequestMapping(value = "/productDetailChartData",method = RequestMethod.GET)
    @ResponseBody
    public Result<Map<String, Object>> productDetailChartData(ProductDetail productDetail) {
        return productClient.productDetailChartData(productDetail);
    }

    @RequestMapping(value = "/trackProduct",method = RequestMethod.POST)
    @ResponseBody
    public Result<Map<String, Object>> trackProduct(ProductDetail productDetail) {
        return productClient.trackProduct(productDetail);
    }

    @RequestMapping(value = "/fiftyProductList",method = RequestMethod.POST)
    @ResponseBody
    public Result<Map<String, Object>> getFiftyProductList(ProductDetail productDetail) {
        return productClient.getFiftyProductList(productDetail);
    }


}

